package tieutruc.persistence.Util;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

public abstract class HibernateUtil extends AbstractBean {
	
private static final long serialVersionUID = 5280020698931861669L;

	public void closeSession(Session session) {
		if (session != null)
			try {
				session.close();
			} catch (HibernateException he) {
				he.printStackTrace();
			}
	}

    public Session getSession() {
        SessionFactory sessionFactory = (SessionFactory) getBean("sessionFactory");
        return sessionFactory.openSession();
    }
    
    
}
